cmake_minimum_required(VERSION 3.18)


project(Function  LANGUAGES CXX)

# function(test a1 a2 a3)

#    message("ARGC = ${ARGC}")      # 实参总个数
#     message("ARGV = ${ARGV}")      # 实参列表；分隔开的字符串
#     message("ARGV0 =${ARGV0}")     # 第一个实参
#     message("ARGV1 =${ARGV1}")     # 第二个实参
#     message("ARGV2 =${ARGV2}")     # 第三个实参
#     message("ARGN = ${ARGN}")      # 剩余的实参列表
    
# endfunction()


# test(1 2 3 4)


function(add a1 a2 )

math(EXPR  ans "${a1}+${a2}")
  #set(res   ${ans}  PARENT_SCOPE) 


  set(res ${ans} CACHE STRING "结果：")

endfunction()


add(1 2)

message(" ${res}")

